ReactJS Ultra For Beginners
⚡ Async React
What is Async React?
- Modern React patterns for handling asynchronous operations
- Includes Suspense, Server Components, and concurrent features
- Improves user experience with better loading states
- Enables more efficient data fetching and rendering
📝 Suspense
Basic Suspense Usage:
import { Suspense } from "react"; function App() { return ( <div> <Suspense fallback={<div>Loading...</div>}> <UserProfile /> </Suspense> </div> ); } function UserProfile() { // This component might suspend during data fetching const user = useUser(); // Custom hook that can suspend return <div>Welcome, {user.name}!</div>; }
Multiple Suspense Boundaries:
function Dashboard() { return ( <div> <Header /> <Suspense fallback={<UserSkeleton />}> <UserInfo /> </Suspense> <Suspense fallback={<PostsSkeleton />}> <RecentPosts /> </Suspense> </div> ); }
🔑 Server Components
Server Component Example:
// This runs on the server async function UserList() { const users = await fetchUsers(); // Server-side data fetching return ( <ul> {users.map((user) => ( <li key={user.id}>{user.name}</li> ))} </ul> ); } // Client Component (runs in browser) ("use client"); function UserActions({ userId }) { const [liked, setLiked] = useState(false); return ( <button onClick={() => setLiked(!liked)}>{liked ? "❤️" : "🤍"}</button> ); }
Mixing Server and Client Components:
// Server Component async function UserProfile({ userId }) { const user = await fetchUser(userId); return ( <div> <h1>{user.name}</h1> <p>{user.email}</p> {/* Client Component for interactivity */} <UserActions userId={userId} /> </div> ); } // Client Component ("use client"); function UserActions({ userId }) { const [isEditing, setIsEditing] = useState(false); return ( <div> <button onClick={() => setIsEditing(true)}>Edit</button> {isEditing && <EditForm userId={userId} />} </div> ); }
🎯 Concurrent Features
useTransition Hook:
import { useTransition, useState } from "react"; function SearchResults() { const [query, setQuery] = useState(""); const [results, setResults] = useState([]); const [isPending, startTransition] = useTransition(); const handleSearch = (newQuery) => { setQuery(newQuery); // Update immediately startTransition(() => { // This update is marked as non-urgent setResults(searchAPI(newQuery)); }); }; return ( <div> <input value={query} onChange={(e) => handleSearch(e.target.value)} placeholder="Search..." /> {isPending && <div>Searching...</div>} <ResultsList results={results} /> </div> ); }
useDeferredValue Hook:
import { useDeferredValue, useState, useMemo } from "react"; function ExpensiveList({ query }) { const deferredQuery = useDeferredValue(query); const filteredList = useMemo(() => { return expensiveFilterOperation(deferredQuery); }, [deferredQuery]); return ( <ul> {filteredList.map((item) => ( <li key={item.id}>{item.name}</li> ))} </ul> ); } function SearchApp() { const [query, setQuery] = useState(""); return ( <div> <input value={query} onChange={(e) => setQuery(e.target.value)} placeholder="Search..." /> <ExpensiveList query={query} /> </div> ); }
🔧 Data Fetching Patterns
Suspense-enabled Data Fetching:
// Custom hook that supports Suspense function useUser(userId) { const userPromise = useMemo(() => { return fetchUser(userId); }, [userId]); const user = use(userPromise); // React 18+ use hook return user; } // Component that can suspend function UserProfile({ userId }) { const user = useUser(userId); // This can suspend return ( <div> <h1>{user.name}</h1> <p>{user.email}</p> </div> ); } // Usage with Suspense function App() { return ( <Suspense fallback={<UserSkeleton />}> <UserProfile userId={123} /> </Suspense> ); }
Error Boundaries with Suspense:
class ErrorBoundary extends React.Component { constructor(props) { super(props); this.state = { hasError: false }; } static getDerivedStateFromError(error) { return { hasError: true }; } render() { if (this.state.hasError) { return <h1>Something went wrong.</h1>; } return this.props.children; } } function App() { return ( <ErrorBoundary> <Suspense fallback={<Loading />}> <UserProfile /> </Suspense> </ErrorBoundary> ); }
🎯 Lazy Loading
Component Lazy Loading:
import { lazy, Suspense } from "react"; const UserProfile = lazy(() => import("./UserProfile")); const Settings = lazy(() => import("./Settings")); function App() { const [currentPage, setCurrentPage] = useState("profile"); return ( <div> <nav> <button onClick={() => setCurrentPage("profile")}>Profile</button> <button onClick={() => setCurrentPage("settings")}>Settings</button> </nav> <Suspense fallback={<div>Loading page...</div>}> {currentPage === "profile" && <UserProfile />} {currentPage === "settings" && <Settings />} </Suspense> </div> ); }
Data Lazy Loading:
function InfiniteScroll() { const [items, setItems] = useState([]); const [page, setPage] = useState(1); const [hasMore, setHasMore] = useState(true); const loadMore = async () => { const newItems = await fetchItems(page); setItems((prev) => [...prev, ...newItems]); setPage((prev) => prev + 1); setHasMore(newItems.length > 0); }; return ( <div> {items.map((item) => ( <Item key={item.id} item={item} /> ))} {hasMore && ( <Suspense fallback={<LoadingMore />}> <LoadMoreButton onLoad={loadMore} /> </Suspense> )} </div> ); }
🔄 Streaming SSR
Streaming Server-Side Rendering:
// Server Component with streaming async function BlogPost({ postId }) { const post = await fetchPost(postId); return ( <article> <h1>{post.title}</h1> <Suspense fallback={<CommentsSkeleton />}> <Comments postId={postId} /> </Suspense> </article> ); } // Comments component that streams in async function Comments({ postId }) { const comments = await fetchComments(postId); return ( <div> {comments.map((comment) => ( <Comment key={comment.id} comment={comment} /> ))} </div> ); }
⚠️ Best Practices
- Use Suspense boundaries strategically - wrap components that can suspend
- Provide meaningful fallbacks - show loading states that match the content
- Handle errors gracefully - use Error Boundaries with Suspense
- Optimize for user experience - use concurrent features for non-urgent updates
- Lazy load appropriately - split code and data loading for better performance
- Test Suspense behavior - ensure your app handles loading states correctly
🔧 Migration Guide
From useEffect to Suspense:
// Old pattern function UserProfile({ userId }) { const [user, setUser] = useState(null); const [loading, setLoading] = useState(true); useEffect(() => { fetchUser(userId) .then(setUser) .finally(() => setLoading(false)); }, [userId]); if (loading) return <div>Loading...</div>; if (!user) return <div>User not found</div>; return <div>{user.name}</div>; } // New pattern with Suspense function UserProfile({ userId }) { const user = useUser(userId); // Can suspend return <div>{user.name}</div>; } // Wrap with Suspense <Suspense fallback={<div>Loading...</div>}> <UserProfile userId={123} /> </Suspense>;
111 / 111 videos100% complete
Course Completed!
Great job! You've finished all videos.
Welcome to the Course
Intro to The Course
3:33How to Learn This Course
3:02What is React and Why You Should Learn It?
4:14Getting Started with React
Installing Nodejs
3:03Setting up a React Development Environment
4:30VSCode Extensions
3:17JavaScript Refresher - All JS You Need To Know Before React
Functions
5:39Ternary and Logical Operators
7:21Objects and Arrays
7:11Map and Filter Functions
7:15Array Function Key Prop
3:13String Templating
4:27Basic React Concepts
React Project Folder Structure
6:55An Intro To JSX
10:33What is the App Component?
2:46How to use Components?
10:23Lists in React
9:45CSS in React
9:10Component Project - Build A Simple Website
First React Project
3:34Making A Navbar
7:11Displaying Images
7:11Making the About Us Section
2:35Creating A Footer
3:38Intro To States In React
What is the useState Hook?
10:38What is the useState Hook? Part 2
4:42What is the useState Hook? Part 3
14:50Intro React Project - Task Tracker App
Beginner Project - Task Tracker App
35:03React Component Lifecycle
The Virtual Dom
1:50React Component Lifecycle
1:42The useEffect Hook
15:40The useEffect Hook Part 2
8:41Routing in React
React Router
14:05React Router Part 2
14:28Advanced Forms In React
Forms in React - React Hook Form
25:36State Management
Intro To State Management - Global States
18:37Beginner Project - Build A Blog App
Intermediate Project - Build A Blog App
40:40Intermediate Project - Build A Blog App Part 2
26:57Other Useful React Hooks
Rules of Hooks
4:05Learn the useReducer Hook
9:54Learn the useRef Hook
12:03Making Your Own Custom Hook
12:10Advanced State Management - Zustand
Why Zustand?
5:22Intro to Zustand
11:08Zustand Subscriptions
9:01Advanced Data Handling With React Query
Why React Query?
6:18The useQuery Hook
16:38The useMutation Hook
8:45Intermediate Project - Build A FullStack Game Manager
What are we building?
2:54Project Demo
2:26Project Structure
5:28Setup REST API
12:43Set Up React Project
6:02Setup the Project Routes
9:12Fetch List of Games
8:13Display List of Games
1:44Create Game Page
20:03Invalidating Queries
5:34Update Game Page
6:05Fetch Game By Id
3:47Reseting the Form
7:21Update Game Endpoint
4:28Update Game Mutation
2:49Invalidating More Queries
2:58Creating the Delete Game Endpoint
1:58Adding the Delete Button
5:28Creating the Theme Manager
11:59Creating the 404 Page Not Found
2:19Thinking In React - Best Practices
Rules of React
4:01Keeping Components Focused
5:08What Are Class Components?
4:19Transition to TypeScript in React
Why Typescript?
3:16Basic Typescript Types
6:23Functions in Typescript
2:41Custom Typescript Types
4:34Unions
3:33Interfaces
5:31Intersections
1:54Enums
2:40Setting Up Typescript in React
4:05Props using Typescript
3:39States using Typescript
3:30Forms using Typescript
2:02Zustand using Typescript
2:16Advanced Final Project - Real Time Chat Messaging App
What are we building?
4:44Project Demo
4:05Project Setup
4:42Setting up SupaBase
8:27Creating the Login Page
8:19Login Page Form Validation
5:15Setting Up Supabase Auth
9:42Supabase Auth Listener
12:04Setting Up Project Routes
11:08Chat Room Page
7:45Creating the Database Table
17:42Loading the Chat Messages
11:04Displaying the Messages
9:44Realtime Messages
9:34Create a New Room Page
11:08List Available Rooms
8:00Testing Strategies in React
Intro to Testing In React
3:25Setup Testing
9:16How to Test A Simple Component?
9:35How to Test User Events?
10:14How to Test Data Fetching?
11:46Bonus: Writing Tests for The Final Project
16:38Async React - React 19 Changes
What is Async React?
6:10Suspense and Lazy Loading
10:37Client vs Server Component
6:56The useTransition Hook
8:35The useDeferredValue Hook
8:33